<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
            list-style: none;
        }
        ul{
            overflow: hidden;
        }
        li{
            float: left;
            width: 100px;
            text-align: center;
            height: 30px;
            cursor: pointer;
        }
        div{
            width: 1000px;
            height: 500px;
            text-align: center;
            line-height: 300px;
            border: 1px solid black;
            display: none;
        }
        img{
            width: 1000px;
            height: 500px;
        }
        li.current{
            background:black;
            color: white;
        }
        div.current{
            display: block;
        }
    </style>
</head>
<body>
    <ul>
        <li class="current">壁纸1</li>
        <li>壁纸2</li>
        <li>壁纸3</li>
        <li>壁纸4</li>
    </ul>
    <section>
        <div class="current"><img src="images/pic1.jpg" alt=""></div>
        <div><img src="images/pic2.jpg" alt=""></div>
        <div><img src="images/pic3.jpg" alt=""></div>
        <div><img src="images/pic4.jpg" alt=""></div>
    </section>
</body>
    <script>
        //获取标签
        var tags=document.getElementsByTagName('li')
        var boxs=document.getElementsByTagName('div')
        //遍历所有标签
        for(var i=0;i<tags.length;i++){
            //自定义标签属性，给每一个li增加一个属性index
            tags[i].index=i;
            tags[i].onclick=function(){
                //排他
                for(var j=0;j<tags.length;j++){
                    tags[j].className=''
                    boxs[j].className=''
                }
                //当前用户点击的增加类
                this.className='current';
                //获取属性
                var n=this.index;
                boxs[n].className='current'
            }
        }
    </script>
</html>